#!/bin/bash
echo get PIOA8

pioa0=0
pioa1=0
pioa2=0
pioa_value=0;

str=`sudo /home/pi/usb2wireless/u2w -remote -gio -port pioa -pin 0`
if grep -q "no response" <<< $str ; then
	echo timeout
	exit 7
fi

if grep -q "HIGH" <<< $str ; then
	let "pioa0+=1"
fi

str=`sudo /home/pi/usb2wireless/u2w -remote -gio -port pioa -pin 1`
if grep -q "no response" <<< $str ; then
        echo timeout
	exit 7
fi

if grep -q "HIGH" <<< $str ; then
        let "pioa1+=2"
fi

str=`sudo /home/pi/usb2wireless/u2w -remote -gio -port pioa -pin 2`
if grep -q "no response" <<< $str ; then
	echo timeout        
	exit 7
fi

if grep -q "HIGH" <<< $str ; then
        let "pioa2+=4"
fi

#echo pioa0=$pioa0
#echo pioa1=$pioa1
#echo pioa2=$pioa2
let "pioa_value=10+(pioa0|pioa1|pioa2)"
echo pioa8: $pioa_value
exit $pioa_value
